﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace Reflection
{
    class Program
    {
        static void Main(string[] args)
        {
            Assembly dll = Assembly.LoadFile(Environment.CurrentDirectory + "\\TestDll.dll");
            Type add = dll.GetType("TestDll.Add", true);
            //MethodInfo method = add.GetMethod("addTest");
            object instance = dll.CreateInstance("TestDll.Add");
            object[] param=new object[2];
            param[0] = 10;
            param[1] = 10;
            Type[] params_type = new Type[2];  
            params_type[0] = Type.GetType("System.Int32"); 
            params_type[1] = Type.GetType("System.Int32"); 
            //int result = (int)method.Invoke(instance, param);
            object value = add.GetMethod("addTest", params_type).Invoke(instance, param); 


            Console.WriteLine(value.ToString());
            Console.ReadLine();  
        }
    }
}
